<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>画线工具箱</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <link rel="stylesheet" href="../font/iconfonMy.css">
    <style>
        body {
            background-color: #f0f0f0;
        }

        * {
            padding: 0;
            color: #000;
            margin: 0;
            font-size: 12px;
            font-family: 'serif';
            box-sizing: border-box;
            cursor: default;
        }

        .hT_list {
            position: relative;
        }

        .l_title {
            line-height: 30px;
            text-align: center;
            padding-top: 7px;
        }

        .l_list {
            display: flex;
            align-items: center;
            text-align: center;
            flex-wrap: wrap;
        }

        .l_item {
            width: 25%;
            padding-top: 5px;
        }

        .btn_wp {
            padding-top: 5px;
            position: absolute;
            /* bottom: 0; */
            left: 0;
            width: 100%;
            display: flex;
            justify-content: space-between;
            padding: 10px 10px 0;
            align-items: center;
        }

        .btn_wp span {
            color: #4545fa;
        }

        .btn {
            border-radius: 3px;
            border: 1px solid #6aade0;
            background-color: #fdfdfd;
            width: 70px;
            text-align: center;
            line-height: 20px;
        }
    </style>
</head>

<body>
    <div id="app">
        <div class="hT_list" v-for="(item,index) in list" :key="index">
            <div class="l_title">{{item.title}}</div>
            <div class="l_list">
                <div class="l_item" v-for="(it,id) in item.list" :key="id" :title="it.type">
                    <input type="checkbox" :value="JSON.stringify(it)" v-model="selectHuTuList"
                        :checked="selectHuTuList.some((item)=>item==JSON.stringify(it))">
                    <i class="iconfonMy" :class="it.icon"></i>
                </div>
            </div>
        </div>
        <div class="btn_wp">
            <span>画图工具使用技巧</span>
            <button class="btn" @click="sumbitHuatu">确定</button>
        </div>
    </div>
</body>
<script>
    const { ipcRenderer, remote } = require('electron');
    new Vue({
        el: '#app',
        data: {
            num: 0,
            selectHuTuList: localStorage.selectHuTuList ? JSON.parse(localStorage.selectHuTuList) : [],
            list: [
                {
                    title: '趋势', list: [{ type: '趋势线', icon: 'icon-xianduan', idx: 1 },
                    { type: '射线', icon: 'icon-shexian', idx: 2 },
                    { type: '水平线', icon: 'icon-hr', idx: 3 },
                    { type: '竖线', icon: 'icon-chuizhixian', idx: 4 },
                    { type: '线段', icon: 'icon-xianduan1', idx: 5 },
                    { type: '指引线', icon: 'icon-jiantou_youxia_o', idx: 6 },
                    { type: '通道线', icon: 'icon-pinghangxian', idx: 7 },
                    { type: '折线', icon: 'icon-MtouWdi', idx: 8 },
                    ]
                },
                {
                    title: '时空', list: [{ type: '箱体', icon: 'icon-changfangxing', idx: 9 },
                    { type: '三角形', icon: 'icon-triangle', idx: 10 },
                    { type: '三弦线', icon: 'icon-bolangxian', idx: 11 },
                    { type: '圆弧', icon: 'icon-yuanhu', idx: 12 },
                    { type: '甘氏线', icon: 'icon-jiangenjiaoduxian', idx: 13 },
                    { type: '阻速线', icon: 'icon-jiangenjiaoduxian', idx: 14 },
                    { type: '对称角度线', icon: 'icon-duichengjiaodu', idx: 15 },
                    { type: '弧线', icon: 'icon-yuanhu1', idx: 16 },
                    { type: '圆', icon: 'icon-yuanhuan', idx: 17 },
                    { type: '椭圆', icon: 'icon-tuoyuan1', idx: 18 },
                    { type: '线性回归带', icon: 'icon-1', idx: 19 },
                    { type: '回归通道', icon: 'icon-2', idx: 20 },
                    ]
                },
                {
                    title: '空间', list: [{ type: '黄金率', icon: 'icon-huangjinshuai', idx: 21 },
                    { type: '百分比线', icon: 'icon-baifenbixian', idx: 22 },
                    { type: '波浪尺', icon: 'icon-bolangchi', idx: 23 },
                    { type: '量度目标', icon: 'icon-ant-price-range', idx: 24 },
                    ]
                },
                {
                    title: '时间', list: [{ type: '周期线', icon: 'icon-zhouqixian', idx: 25 },
                    { type: '斐波那契时间序列', icon: 'icon-feibonaqizhouqixian', idx: 26 },
                    { type: '斐波那契时间扩展', icon: 'icon-feibonaqizhouqixian', idx: 27 }]
                },
                {
                    title: '工具', list: [{ type: '符号', icon: 'icon-kongxinshangjiantou', idx: 28 },
                    { type: '时间尺', icon: 'icon-TimeRuler', idx: 29 },
                    { type: '价差尺', icon: 'icon-SpreadRuler', idx: 30 },
                    { type: '标注、标价', icon: 'icon-ABC', idx: 31 },
                    { type: '画线颜色', icon: 'icon-yk_fangkuai_fill', idx: 32 },
                    { type: '删除', icon: 'icon-xiangpicaB', idx: 33 },
                    { type: '画线列表及管理', icon: 'icon-shezhi', idx: 34 }]
                },
            ]
        },
        created() {
            ipcRenderer.on('huaTuNumber', (e, v) => {
                let menu = JSON.parse(v)
                menu.forEach((item, index) => {
                    if (item.show && index < 24) {
                        this.num++
                    }
                });
            })

        },
        methods: {
            sumbitHuatu() {
                const parentWindow = remote.getCurrentWindow().getParentWindow();
                const parentWidth = parentWindow.getBounds().width;
                let maxNum = parseInt((parentWidth - 340) / 31)
                if (this.num + this.selectHuTuList.length > maxNum) { return alert('菜单数量超过最大限制') }
                localStorage.setItem('selectHuTuList', JSON.stringify(this.selectHuTuList))
                ipcRenderer.send('closeHuaTuGj', this.selectHuTuList);
            }
        },
    })
</script>

</html>